clear all
//set maxvar 120000
cd "C:\Users\mrabier\Dropbox\JOLE WARN Act\analysis/data/built"
use "cps_built_final_sample.dta", clear
cd "C:\Users\mrabier\Dropbox\JOLE WARN Act\analysis/output/"


*****************************************************************************************
* Table 2 Panel A Simple Tabs - Does the passage of the WARN Act result in more Advanced Notice?
*****************************************************************************************

cd "C:/Users/mrabier/Dropbox/JOLE WARN Act/analysis/output/"

preserve

drop if ONETHIRDWAIVER == 0 & PLANTCLOSING == 0 & EVENTUALTREAT == 1

* Keep only treated states
drop POSTTREAT

* Step 1: Define the implementation year by state
gen imp_year = .
replace imp_year = 2003 if STATEFIP == 6   // CA
replace imp_year = 2005 if STATEFIP == 17  // IL
replace imp_year = 2007 if STATEFIP == 34  // NJ
replace imp_year = 2009 if STATEFIP == 36  // NY
replace imp_year = 2010 if STATEFIP == 19  // IA
replace imp_year = 2010 if STATEFIP == 33  // NH
replace imp_year = 2015 if STATEFIP == 50  // VT
replace imp_year = . if !inlist(STATEFIP, 6, 17, 34, 36, 19, 50, 33) // Never treated states

* Step 2: Create relative year variable
gen rel_year = LOSSYEAR - imp_year

* Step 3: Keep only +/- 5 years around adoption for treated states
gen keep_window = (rel_year >= -5 & rel_year <= 4) if !missing(imp_year)

replace keep_window = 1 if missing(imp_year) // Keep all never-treated observations
keep if keep_window == 1
* Step 4: Define POSTTREAT indicator for treated states
gen POSTTREAT = (rel_year >= 0) if !missing(imp_year)
* Define the three categories
gen group = .
replace group = 1 if !missing(imp_year) & POSTTREAT == 0 // Treated states pre-period
replace group = 2 if !missing(imp_year) & POSTTREAT == 1 // Treated states post-period
replace group = 3 if missing(imp_year) // Never treated states

* Collapse to means by group
collapse (mean) NOTICEBIN NOTICELEN NOTICEORD, by(group)

by group, sort: sum NOTICEBIN NOTICELEN NOTICEORD, d

restore

****************************************************************************************
*Table 2 Panel B (Regressions): Does the passage of the WARN Act result in more Advanced Notice?
****************************************************************************************
preserve

drop if ONETHIRDWAIVER == 0 & PLANTCLOSING == 0 & EVENTUALTREAT == 1

* Clear previous stored estimates
eststo clear

* Define your variable list
local indepvars POSTTREAT FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP i.DWOCC1990 i.STATEFIP i.LOSSYEAR

* Run first regression
reg NOTICEBIN `indepvars', vce(cluster STATEFIP)
eststo noticebin
boottest POSTTREAT, cluster(STATEFIP) seed(12345) weighttype(webb) reps(9999) ptype(equaltail) jk
estadd scalar wild_p = r(p)
esttab noticebin, scalars(wild_p)

* Run second regression
reg NOTICELEN `indepvars', vce(cluster STATEFIP)
eststo noticelen
boottest POSTTREAT, cluster(STATEFIP) seed(12345) weighttype(webb) reps(9999) ptype(equaltail) jk
estadd scalar wild_p = r(p)

* Run third regression
reg NOTICEORD `indepvars', vce(cluster STATEFIP)
eststo noticeord
boottest POSTTREAT, cluster(STATEFIP) seed(12345) weighttype(webb) reps(9999) ptype(equaltail) jk
estadd scalar wild_p = r(p)


	
* Export results to RTF file with wild bootstrap p-values and SEs
esttab noticebin noticelen noticeord using results_table.tex, ///
    title("Effect of POSTTREAT on Notice Outcomes") ///
    b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
    drop(*.STATEFIP *.LOSSYEAR *.DWOCC1990) ///
    stats(N r2 wild_p, labels("Observations" "R-squared" "Wild p-value") ///
          fmt(0 3 3)) ///
    scalar(wild_p) ///
    addnote("All models include State, Year, and Occupation fixed effects") ///
    replace

****************************************************************************************
*Table OA.5 Gardner 2021 Robustness Check
****************************************************************************************

	
eststo clear

did2s NOTICEBIN, first_stage(FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP ///
        i.LOSSYEAR i.STATEFIP i.DWOCC1990) second_stage(POSTTREAT) ///
        treatment(POSTTREAT) cluster(STATEFIP)
eststo noticebin

did2s NOTICELEN, first_stage(FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP ///
        i.LOSSYEAR i.STATEFIP i.DWOCC1990) second_stage(POSTTREAT) ///
        treatment(POSTTREAT) cluster(STATEFIP)
eststo noticelen

did2s NOTICEORD, first_stage(FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP ///
        i.LOSSYEAR i.STATEFIP i.DWOCC1990) second_stage(POSTTREAT) ///
        treatment(POSTTREAT) cluster(STATEFIP)
eststo noticeord

* Export side-by-side regression table
esttab noticebin noticelen noticeord using did2s_results.tex, replace se b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
       title("Gardner (2021) DID2S Estimates of State WARN Acts on Notice") label
	

*** clogit Robustness Check***
	
eststo clear


* Conditional logit for binary notice (online appendix)
clogit NOTICELEN POSTTREAT FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG ///
       NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP i.LOSSYEAR i.DWOCC1990_GROUP, ///
       group(STATEFIP) vce(cluster STATEFIP)
eststo noticebin_cl



* Export
esttab noticebin_cl using clogit_notice.tex, replace se ///
      b(%9.3f) se(%9.3f) star(* 0.10 ** 0.05 *** 0.01) ///
      title("Conditional logit for Lengthy Notice") label
	
	
	
	
restore

****************************************************************
*Table OA.6: Law Features
****************************************************************

// small vs large firms

eststo clear

cd "C:\Users\mrabier\Dropbox\JOLE WARN Act\analysis/output/"

gen minsize = .

replace minsize = 75 if STATEFIP == 06   // CA
replace minsize = 75 if STATEFIP == 17   // IL
replace minsize = 100 if STATEFIP == 34  // NJ
replace minsize = 50 if STATEFIP == 36   // NY
replace minsize = 100 if STATEFIP == 33  // NH
replace minsize = 25 if STATEFIP == 19   // IA
replace minsize = 50 if STATEFIP == 50   // VT

gen LARGE = (minsize >50)
replace LARGE =[.] if minsize ==[.]

g POSTTREAT_LARGE = 0
replace POSTTREAT_LARGE = 1 if POSTTREAT ==1 & LARGE ==1

g POSTTREAT_SMALL = 0
replace POSTTREAT_SMALL = 1 if POSTTREAT ==1 & LARGE ==0

// generate Private Right to Action variable

gen PRA = .

replace PRA = 1 if STATEFIP == 06   // California - Yes
replace PRA = 1 if STATEFIP == 36   // New York - Yes
replace PRA = 1 if STATEFIP == 33   // New Hampshire - Yes
replace PRA = 1 if STATEFIP == 34   // New Jersey - Yes (with caps)

replace PRA = 0 if STATEFIP == 19   // Iowa - No
replace PRA = 0 if STATEFIP == 50   // Vermont - No
replace PRA = 0 if STATEFIP == 17   // Illinois - No

label define pra_lbl 0 "No Private Right" 1 "Private Right"
label values PRA pra_lbl

gen POSTTREAT_PRA = 0
replace POSTTREAT_PRA = 1 if POSTTREAT == 1 & PRA == 1

gen POSTTREAT_NOPRA = 0
replace POSTTREAT_NOPRA = 1 if POSTTREAT == 1 & PRA == 0

// one third waiver rule

gen POSTTREAT_ONETHIRD = 0
replace POSTTREAT_ONETHIRD = 1 if POSTTREAT == 1 & ONETHIRDWAIVER == 1

gen POSTTREAT_NONETHIRD = 0
replace POSTTREAT_NONETHIRD = 1 if POSTTREAT == 1 & ONETHIRDWAIVER == 0


//regressions

* Define your variable list

* === Size-Based Law Feature Model ===
preserve

drop if ONETHIRDWAIVER == 0 & PLANTCLOSING == 0 & EVENTUALTREAT == 1

reg NOTICELEN POSTTREAT_LARGE POSTTREAT_SMALL FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN ///
    GDPPERCAPITA UNEMPRATE EMPPOP i.DWOCC1990 i.STATEFIP i.LOSSYEAR, vce(cluster STATEFIP)

	test POSTTREAT_SMALL = POSTTREAT_LARGE

eststo noticelen_size

boottest POSTTREAT_LARGE, cluster(STATEFIP) seed(12345) weighttype(webb) reps(9999) jk
scalar wild_p_large = r(p)
estimates restore noticelen_size
estadd scalar wild_p_large = wild_p_large

boottest POSTTREAT_SMALL, cluster(STATEFIP) seed(12345) weighttype(webb) reps(9999) jk
scalar wild_p_small = r(p)
estimates restore noticelen_size
estadd scalar wild_p_small = wild_p_small


* === PRA-Based Law Feature Model ===

drop if ONETHIRDWAIVER == 0 & PLANTCLOSING == 0 & EVENTUALTREAT == 1

reg NOTICELEN POSTTREAT_PRA POSTTREAT_NOPRA FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN ///
    GDPPERCAPITA UNEMPRATE EMPPOP i.DWOCC1990 i.STATEFIP i.LOSSYEAR, vce(cluster STATEFIP)
		test POSTTREAT_PRA = POSTTREAT_NOPRA

eststo noticelen_pra

boottest POSTTREAT_PRA, cluster(STATEFIP) seed(12345) weighttype(webb) reps(9999) jk
scalar wild_p_pra = r(p)
estimates restore noticelen_pra
estadd scalar wild_p_pra = wild_p_pra

boottest POSTTREAT_NOPRA, cluster(STATEFIP) seed(12345) weighttype(webb) reps(9999) jk
scalar wild_p_nopra = r(p)
estimates restore noticelen_pra
estadd scalar wild_p_nopra = wild_p_nopra

restore

* === One-Third Waiver Model ===
reg NOTICELEN POSTTREAT_ONETHIRD POSTTREAT_NONETHIRD FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN ///
    GDPPERCAPITA UNEMPRATE EMPPOP i.DWOCC1990 i.STATEFIP i.LOSSYEAR if PLANTCLOSING == 0, vce(cluster STATEFIP)
eststo noticelen_onethird

		test POSTTREAT_ONETHIRD = POSTTREAT_NONETHIRD

		
boottest POSTTREAT_ONETHIRD, cluster(STATEFIP) seed(12345) weighttype(webb) reps(9999) jk
scalar wild_p_onethird = r(p)
estimates restore noticelen_onethird
estadd scalar wild_p_onethird = wild_p_onethird

boottest POSTTREAT_NONETHIRD, cluster(STATEFIP) seed(12345) weighttype(webb) reps(9999) jk
scalar wild_p_nonethird = r(p)
estimates restore noticelen_onethird
estadd scalar wild_p_nonethird = wild_p_nonethird


* === Export Table ===
esttab noticelen_size noticelen_pra noticelen_onethird using lawfeatureresults_table.tex, ///
    title("Effect of POSTTREAT on Notice Outcomes by Legal Features") ///
    b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
    drop(*.STATEFIP *.LOSSYEAR *.DWOCC1990) ///
    stats(N r2 ///
          wild_p_large wild_p_small ///
          wild_p_pra wild_p_nopra ///
          wild_p_onethird wild_p_nonethird, ///
          labels("Observations" "R-squared" ///
                 "Wild p (Large)" "Wild p (Small)" ///
                 "Wild p (PRA)" "Wild p (No PRA)" ///
                 "Wild p (One-Third)" "Wild p (No One-Third)") ///
          fmt(0 3 3 3 3 3 3 3)) ///
    scalar(wild_p_large wild_p_small wild_p_pra wild_p_nopra wild_p_onethird wild_p_nonethird) ///
    addnote("All models include State, Year, and Occupation fixed effects") ///
    replace



*******************************************************************
*- Table 3 Advanced Notice on Job Displacement Outcomes 
*******************************************************************

drop if ONETHIRDWAIVER == 0 & PLANTCLOSING == 0 & EVENTUALTREAT == 1

cd "C:/Users/mrabier/Dropbox/JOLE WARN Act/analysis/output/"

eststo clear

ttest JOBLESS, by(NOTICELEN)
ttest JOBLESSGT1WK, by(NOTICELEN)
ttest DWWKSUN, by(NOTICELEN)
ttest CUREMP, by(NOTICELEN)
ttest FTtoPT, by(NOTICELEN)
ttest DWWEEKCLOG, by(NOTICELEN)

* Define dependent and independent variables with short labels
local DEPVARS JOBLESS J1W WKS CEMP FTP DWWEEKC
local DEP_LABELS JOBLESS JOBLESSGT1WK DWWKSUN CUREMP FTtoPT DWWEEKCLOG
local INDEPSET NOTICELEN NOTICEBIN NOTICEORD
local CONTROLS FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP 

* Mapping for exporting labels
local i = 1
foreach indep in `INDEPSET' {
    
    * Clear estimation store for each indep var loop
    eststo clear

    * Panel A: Simple OLS (no controls, no FEs)
    local j = 1
    foreach dep in `DEPVARS' {
        local dep_label : word `j' of `DEP_LABELS'
        reg `dep_label' `indep'
        eststo simp_`dep'_`indep'
        boottest `indep', cluster(STATEFIP) weighttype(webb) reps(9999) seed(12345) ptype(equaltail) jk
        estadd scalar wild_p = r(p)
        estadd local Controls "N", replace
        estadd local FE "N", replace
        local ++j
    }

    * Panel B: OLS with controls + fixed effects
    local j = 1
    foreach dep in `DEPVARS' {
        local dep_label : word `j' of `DEP_LABELS'
        reg `dep_label' `indep' `CONTROLS' i.STATEFIP i.LOSSYEAR i.DWOCC1990, vce(cluster STATEFIP)
        boottest `indep', cluster(STATEFIP) weighttype(webb) reps(9999) seed(12345) ptype(equaltail) jk
        eststo adj_`dep'_`indep'
        estadd scalar wild_p = r(p)
        estadd local Controls "Y", replace
        estadd local FE "Y", replace
        local ++j
    }

    * Define short output file name
    local outfile = lower("noticecorr_`indep'")

	/*
    * Export Panel A
    esttab simp_JOBLESS_`indep' simp_J1W_`indep' simp_WKS_`indep' simp_CEMP_`indep' simp_FTP_`indep' ///
        using `outfile'.rtf, ///
        title("Table X: Correlation Between `indep' and Worker Outcomes – Simple Models") ///
        mtitles("Jobless" "Jobless >1wk" "Weeks Unemp." "Re-employed" "FT→PT") ///
        b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
        keep(`indep') ///
        stats(N r2 wild_p Controls FE, ///
              labels("Observations" "R-squared" "Wild p-value" "Controls" "Year, State, Occ FE")) ///
        label nonotes replace
*/
    * Export Panel B
esttab adj_JOBLESS_`indep' adj_J1W_`indep' adj_WKS_`indep' adj_CEMP_`indep' adj_FTP_`indep' adj_DWWEEKC_`indep' ///
    using `outfile'.tex, append ///
    mtitles("Jobless (Adj.)" "Jobless >1wk (Adj.)" "Weeks Unemp. (Adj.)" "Re-employed (Adj.)" "FT→PT (Adj.)" "Weekly Earnings (Adj.)") ///
    b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
    keep(`indep') ///
    stats(N r2 wild_p Controls FE, ///
          labels("Observations" "R-squared" "Wild p-value" "Controls" "Year, State, Occ FE")) ///
    label nonotes

}



*****************************************************************
*Table OA.9 Relationship between WARN Law and Outcomes 
***************************************************************** 

eststo clear

local INDEPVAR POSTTREAT FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP 


* Panel B: OLS with controls + fixed effects
foreach dep in JOBLESS JOBLESSGT1WK DWWKSUN CUREMP FTtoPT DWWEEKCLOG {
    reg `dep' POSTTREAT `INDEPVAR' i.STATEFIP i.LOSSYEAR i.DWOCC1990, vce(cluster STATEFIP)
    boottest POSTTREAT, cluster(STATEFIP) reps(9999) seed(12345)
    local wildp = r(p)
    eststo adjusted_`dep'
    estadd scalar wild_p = `wildp'
    estadd local Controls "Y", replace
    estadd local FE "Y", replace
}

* Export Panel B: Adjusted models (append below)
esttab adjusted_JOBLESS adjusted_JOBLESSGT1WK adjusted_DWWKSUN adjusted_CUREMP adjusted_FTtoPT adjusted_DWWEEKCLOG ///
       using posttreat_outcomes.tex, ///
    title("Table X (cont.): Adjusted Models with Controls and Fixed Effects") ///
    mtitles("Jobless (Adj.)" "Jobless >1wk (Adj.)" "Weeks Unemp. (Adj.)" "Re-employed (Adj.)" "FT→PT (Adj.)") ///
    b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
    keep(POSTTREAT) ///
    stats(N r2 wild_p Controls FE, ///
          labels("Observations" "R-squared" "Wild p-value" "Controls" "Year, State, Occ FE")) ///
    label nonotes replace




*****************************************************************
*Table 4 IV Regression
***************************************************************** 

cd "C:\Users\mrabier\Dropbox\JOLE WARN Act\analysis/output/"

eststo clear
local INDEPVAR FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP 

foreach DEPVAR in JOBLESS JOBLESSGT1WK DWWKSUN CUREMP FTtoPT DWWEEKCLOG  {
    foreach INTR in NOTICELEN {

        * Run the IV regression with diagnostics
        ivreg2 `DEPVAR' `INDEPVAR' i.LOSSYEAR i.STATEFIP i.DWOCC1990 ///
            (`INTR' = POSTTREAT), cluster(STATEFIP) first liml 

        * Capture test statistics
        scalar KP_F = e(rkf)                      // Kleibergen-Paap Wald rk F
        scalar AR_F = e(arf)                     // Anderson-Rubin F
        scalar AR_p = e(arfp)                // p-value for AR F
        scalar AR_chi2 = e(archi2)               // Anderson-Rubin chi2
        scalar AR_chi2_p = e(archi2p)        // p-value for AR chi2

			
        * Attach custom statistics to the stored estimation result
        estadd scalar KP_F = KP_F
        estadd scalar AR_F = AR_F
        estadd scalar AR_p = AR_p
        estadd scalar AR_chi2 = AR_chi2
        estadd scalar AR_chi2_p = AR_chi2_p

			* Run wild bootstrap test on the endogenous variable
        boottest `INTR' = 0, cluster(STATEFIP) weighttype(webb) reps(9999) seed(12345) ptype(equaltail) jk
        estadd scalar wild_p = r(p) 
		
		* Add indicators for controls and fixed effects
        estadd local Controls "Yes", replace
        estadd local FixedEffects "Yes (State, Year, Occupation)", replace
				
     * Store this model under a unique name
        eststo `DEPVAR'
    }
}

* Export to CSV with labels and notes
esttab using ivreg2_controls.tex, ///
    se b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) ///
	keep(NOTICELEN) ///
    stats(N r2 KP_F AR_F AR_p AR_chi2 AR_chi2_p wild_p Controls FE, ///
          labels("Observations" "R-squared" "Kleibergen-Paap F" "AR F" "AR p" "AR chi2" "AR chi2 p" "Wild p-value" "Controls" "Fixed Effects")) ///
    label compress replace nonumber ///
    addnotes("999 Wild bootstrap replications, clustered at state level") ///
    title("Wild Bootstrap IV Regressions with Controls and Fixed Effects")

********************************************************
*Table 5 LARF
*********************************************************

* Define covariates
local INDEPVAR FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP 

* Generate instrument

probit POSTTREAT `INDEPVAR' i.DWOCC1990 
predict PRED
gen KAPPA = 1-(NOTICELEN*(1-POSTTREAT))/(1-PRED) - ((1-NOTICELEN)*(POSTTREAT))/(PRED)

*---------------------------*
* WITH CONTROLS — NO LOOP  *
*---------------------------*
capture erase larf_controls.tex
cd "C:\Users\mrabier\Dropbox\JOLE WARN Act\analysis/output/"

* JOBLESS
reg JOBLESS NOTICELEN `INDEPVAR' i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA], vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum JOBLESS if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_controls.tex, replace keep(NOTICELEN) ctitle(Jobless) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons

* JOBLESSGT1WK
reg JOBLESSGT1WK NOTICELEN `INDEPVAR' i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA], vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum JOBLESSGT1WK if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_controls.tex, append keep(NOTICELEN) ctitle(Jobless > 1 wk) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons

* DWWKSUN
reg DWWKSUN NOTICELEN `INDEPVAR' i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA], vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum DWWKSUN if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_controls.tex, append keep(NOTICELEN) ctitle(Weeks Unemployed) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons

* CUREMP
reg CUREMP NOTICELEN `INDEPVAR' i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA], vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum CUREMP if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_controls.tex, append keep(NOTICELEN) ctitle(Currently Employed) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons

* FTtoPT
reg FTtoPT NOTICELEN `INDEPVAR' i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA], vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum FTtoPT if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_controls.tex, append keep(NOTICELEN) ctitle(Full to Part-time) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons
	
* DWWEEKCLOG
reg DWWEEKCLOG NOTICELEN `INDEPVAR' i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA], vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum FTtoPT if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_controls.tex, append keep(NOTICELEN) ctitle(Log (Current Earnings)) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons
	

*************************************
*Table 6 LARF Cross Sectional 
*************************************

********************************************
* FEMALE AND MALE
********************************************
cd "C:\Users\mrabier\Dropbox\JOLE WARN Act\analysis/output/"

reg JOBLESSGT1WK NOTICELEN FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA] if SEX == 1, vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum JOBLESSGT1WK if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_split.tex, append keep(NOTICELEN) ctitle(male) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons

reg JOBLESSGT1WK NOTICELEN FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA] if SEX == 2, vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum JOBLESSGT1WK if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_split.tex, append keep(NOTICELEN) ctitle(female) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons

********************************************
* UNION AND NON UNION
********************************************
reg JOBLESSGT1WK NOTICELEN FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA] if UNION ==1, vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum JOBLESSGT1WK if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_split.tex, append keep(NOTICELEN) ctitle(Union) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons

reg JOBLESSGT1WK NOTICELEN FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA] if UNION ==0, vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum JOBLESSGT1WK if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_split.tex, append keep(NOTICELEN) ctitle(Non union) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons

********************************************
* WAGE QUANTILES
********************************************
xtile WAGEQ = DWWEEKL, nq(10)

reg JOBLESSGT1WK NOTICELEN FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA] if WAGEQ < 5, vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum JOBLESSGT1WK if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_split.tex, append keep(NOTICELEN) ctitle(low wage) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons
	
reg JOBLESSGT1WK NOTICELEN FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA] if  WAGEQ > 5, vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum JOBLESSGT1WK if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_split.tex, append keep(NOTICELEN) ctitle(high_wage) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons

********************************************
* SKILL
********************************************

reg JOBLESSGT1WK NOTICELEN FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA] if  EDUC < 13, vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum JOBLESSGT1WK if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_split.tex, append keep(NOTICELEN) ctitle(Low skill) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons

reg JOBLESSGT1WK NOTICELEN FULLTIME UNION YEARS HI MARITAL EDUC AGE DWWEEKLLOG NCHILDBIN GDPPERCAPITA UNEMPRATE EMPPOP i.STATEFIP i.LOSSYEAR i.DWOCC1990 [iweight = KAPPA] if  EDUC > 12, vce(cluster STATEFIP)
boottest NOTICELEN, cluster(STATEFIP) reps(999) seed(12345)
scalar wild_t = r(t)
scalar wild_p = r(p)
sum JOBLESSGT1WK if e(sample)
local mymean : di %8.2fc r(mean)
outreg2 using larf_split.tex, append keep(NOTICELEN) ctitle(High skill) ///
    addtext(Controls, Y, Year State Occ FE, Y, Dep. Var. Mean, `mymean', Wild t, `=wild_t', Wild p, `=wild_p') label nonotes nocons
	
